//
//  ExpresserCell.m
//  TengyunStation
//
//  Created by Johnny on 15/8/24.
//  Copyright (c) 2015年 xingrong. All rights reserved.
//

#import "ExpresserCell.h"
#import "TSHeader.h"

@implementation ExpresserCell

- (void)awakeFromNib {
    // Initialization code
    UILabel *line = [[UILabel alloc] initWithFrame:CGRectMake(0, 54.5, 200, 0.5)];
    line.backgroundColor = LineColor;
    [self addSubview:line];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)reloadExpresserCellWithExpresserModel:(ExpresserDBModel *)expresser Text:(NSString *)text {
    _titleLabel.text = [NSString stringWithFormat:@"%@(%@)",expresser.expressCompanyName,expresser.expresserName];
    _phoneLabel.attributedText = [self phone:expresser.telephone Text:text];
}

- (NSAttributedString *)phone:(NSString *)phone Text:(NSString *)text {
    NSRange range = [phone rangeOfString:text];
    NSMutableAttributedString *attriString = [[NSMutableAttributedString alloc] initWithString:phone];
    [attriString addAttribute:NSForegroundColorAttributeName value:OrangeColor range:range];
    return attriString;
}

- (IBAction)removeCurrentExpresser:(id)sender {
    if ([_delegate respondsToSelector:@selector(removeExpresserCell:)]) {
        [_delegate removeExpresserCell:self];
    }
}
@end
